Skip to content

fix(minting-service): bundle Vercel functions via Nx esbuild build#133

Merged
blove merged 1 commit into
mainfrom
feat/minting-service-vercel-nx-build
Apr 21, 2026
Merged

fix(minting-service): bundle Vercel functions via Nx esbuild build#133
blove merged 1 commit into
mainfrom
feat/minting-service-vercel-nx-build

Conversation

@blove
Copy link
Copy Markdown
Contributor

@blove blove commented Apr 21, 2026

Summary

  • Adds an Nx build target for minting-service that bundles each api/*.ts with esbuild and emits Vercel Build Output API v3 layout under .vercel/output/.
  • Workspace deps (@cacheplane/db, @cacheplane/licensing) are inlined via tsconfig paths — no changes to workspaces or libs' package.json entry points required.
  • Replaces the prior tsc --noEmit buildCommand, which only type-checked and left Vercel to compile TS at deploy time (where @cacheplane/* wouldn't resolve).

Why this approach

  • @nx/esbuild isn't installed in this repo; using nx:run-commands with a small scripts/build.mjs keeps the dep surface minimal (esbuild is already transitively available).
  • Build Output API v3 sidesteps Vercel's default api/*.ts scan, so the TS sources stay as source-only and the built .js functions live in .vercel/output/ (gitignored).
  • Each .func/ directory ships a colocated package.json with "type": "commonjs" to override the app's "type": "module" — otherwise Node loads the CJS bundle as ESM and silently yields an empty module.

Test plan

  • npx nx build minting-service produces .vercel/output/functions/api/{health,stripe-webhook}.func/index.js + valid .vc-config.json
  • require()-loading each bundle yields the expected default handler function (and config.api.bodyParser: false on the webhook)
  • npx nx test minting-service — all tests pass
  • Vercel redeploy succeeds and /api/health returns {ok:true} in production

🤖 Generated with Claude Code

The prior `tsc --noEmit` buildCommand didn't emit any JS, so Vercel
would still try to compile `api/*.ts` directly at deploy time. That
path can't resolve `@cacheplane/db` or `@cacheplane/licensing` because
`libs/*` isn't in the root npm workspaces and the libs don't declare
`exports` entry points.

Switch to Nx-native build: a new `build` target runs esbuild over
every `api/*.ts`, inlining workspace deps via tsconfig paths and
emitting Vercel Build Output API v3 layout under `.vercel/output/`.
Each `.func` colocates a `package.json` pinning `commonjs` to override
the app's `"type": "module"`.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cacheplane Ready Ready Preview, Comment Apr 21, 2026 7:05pm

Request Review

@blove blove merged commit fc73d3e into main Apr 21, 2026
14 checks passed
@blove blove deleted the feat/minting-service-vercel-nx-build branch April 21, 2026 19:09
blove added a commit that referenced this pull request Apr 21, 2026
…loy (#134)

The Nx esbuild build (PR #133) produced a correct Build Output API v3
layout under `.vercel/output/functions/api/*.func/`, but Vercel's
default Node builder still auto-detects `api/*.ts` at the project root
and runs `@vercel/node` on top of our output. That failed with
`api/health.ts: Emit skipped` because @vercel/node's tsc doesn't
resolve the workspace tsconfig paths.

Rename `apps/minting-service/api/` → `apps/minting-service/handlers/`
so Vercel's auto-detection finds nothing and falls back to the Build
Output API our buildCommand already produces. The deployed URL path
(`/api/health`, `/api/stripe-webhook`) is unchanged — esbuild still
emits to `.vercel/output/functions/api/<name>.func/`.

Co-authored-by: Claude Opus 4 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant